<?php
namespace Common\Model;
use Common\Model\BaseModel;
/**
* 标签model
*/
Class ArticleGradeModel extends BaseModel{
    // 添加标签
    public function addData($aid,$data){

        foreach ($data as $v) {
            if (!empty($v)) {
                $data = array(
                    'aid' => $aid,
                    'grade' => $v['grade'],
                    'g_num' => $v['g_num'],
                );
                $this->add($data);
            }
        }
        return true;
    }




    // 根据Aid获取单条数据
    public function getDataByAid($aid){

       $data= $this->where(array('aid'=>$aid))->order('grade asc')->select();
        foreach($data as $k=>$v){
            $data[$k]['grade1']=makeoption('grade')[$v['grade']-1];
        }

        return $data;
    }


    public function deleteData($aid){

       $this->where(array('aid'=>$aid))->delete();

        return true;

    }




}
